<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%String s = request.getServerName()+":"+request.getServerPort()+path+"/";
  request.setAttribute("s",s);
  %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'verifyMailbox.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" href="${pageContext.request.contextPath }/statics/css/reveal.css">	
	<link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath }/statics/css/email.css">
	<script type="text/javascript"  src="${pageContext.request.contextPath }/statics/js/jquery-1.8.3.js"  ></script>
  	<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/jquery.reveal.js"></script>
	<style type="text/css">

			body { font-family: "HelveticaNeue","Helvetica-Neue", "Helvetica", "Arial", sans-serif; }
	       .big-link { display:block; margin-top: 100px; text-align: center; font-size: 70px; color: #06f; }

		</style>
  </head>
    
  
  
  
  
  <script type="text/javascript">

  </script>
  <body>
 
 <div class="back">
  <div class="title"  ><span>请输入邮箱中的验证码，确保您的邮箱真实有效</span></div>
 <form class="form" >
 <div style="width: 900px; float: left;   margin-left:20%;">
 <span id="emailQWE">邮箱:<%=request.getParameter("email") %></span><br><br></div>
 <div style="width: 900px; float: left;   margin-left:20%;">
<span><font color="red">*</font>验证码 ：</span>
<input type="hidden"  name="email" value="<%=request.getParameter("email")%>">
<input type="hidden" name="action" value="1">
<input  class=“Myex” type="text"  name="validateCode" style=" 
	border-radius:2px;
	border:1px solid #00BFFF;
	text-align:center;
    font-size:1.2em;
    height:1.9em;
    width:200px; position: relative;
    bottom: 5px;
    ">
<input type="button"  id="btn" value="获取验证码"     onclick="settime(this)" style=" 

	
	border-bottom:1px solid ;
	border-right:1px solid ;
	border-top:1px solid ;	
		text-align:center;
    font-size:1.0em;
    height:1.9em;
    background-color:#EEEEEE;
  color:gray ;
    ">
<font class="gg" size="2px;">请查收您的邮箱，并填写邮箱中的验证码<br>(此验证码3分钟有效)</font>
</div>
<br><br>
<input  id="submit" value="注册" style="
	border-radius:6px;
	border:1px solid #4169E1;
	background-color:#1E90FF;
	text-align:center;
    font-size:1.0em;
    height:3.0em;
    width:50%;
    position: relative;
    bottom: 0px;
    left:10%;
	color: white; ">

 </form>
 </div>
 
		<div id="myModal" class="reveal-modal">

			<h1>邮箱已成功激活</h1>

			<p>
			<span id="miao">5</span>秒后跳转至登录页面或<a href="login.jsp">点击跳转</a>
			</p>

			
			<a class="close-reveal-modal">&#215;</a>

		</div>
  </body>
   <script type="text/javascript">
   
   var time =5; 
   function load(node){
   		if(time!=1){
   		time--;
   		node.html(time);
   		}else{
   		window.location.href="login.jsp";
   		return;
   		}
   setTimeout(function() { 
   load($("#miao"))},1000);
   }
   
   
    var countdown=60; 
  	function settime(obj) { 
    	if (countdown == 0) { 
   	 		obj.removeAttribute("disabled"); 
    		obj.value="免费获取验证码"; 
  			countdown = 60; 
  			return;
  		} else { 
  			obj.setAttribute("disabled", true); 
 			obj.value="重新发送(" + countdown + ")"; 
  			countdown--; 
  		}
   
  		setTimeout(function() { 
  		settime(obj)},1000);
  
  							}
   
   
   
   
  $(function(){
	  
	  $("#btn").click(function(){
		  
		  var email=$("[name=email]").val();
		   $.getJSON("sendemailtoadduser",{"email":email},function(result){
			   
			   if(result==false){
				   alert("网络异常");
			   }else{
				   alert("邮箱发送成功请查看");
			   }
			   
		   });
		
		
		   $("#submit").click(function(){
			   var v=$("[name=validateCode]").val();
			   var email=$("[name=email]").val();
			   
			  // alert(v+email);
			   $.getJSON("${pageContext.request.contextPath }/user/registers",{"validateCode":v,"email":email},function(result){
				 console.log(result);
				 alert(result);
				  /*  if(result==false){
					   alert("验证码错误请重新发送");
					   return false;
				   }else{
					   
					   window.location.href="login.jsp";
				   }
				    */
				   
			   });
			   
			   
			   
		   });
		   
		   
		   
	  });
	  
	  
var webSocket = new WebSocket("ws://192.168.137.1:8080/apply/ws");


window.onbeforeunload = function(){
     webSocket.close();
   };


webSocket.onopen = function(event){
      console.log("连接成功");
      console.log(event);


};

webSocket.onerror = function(event){
    console.log("连接失败");
    console.log(event);
};

webSocket.onclose = function(event){
    console.log("Socket连接断开");
    console.log(event);
};

webSocket.onmessage = function(event){
    //接受来自服务器的消息

   var data = $.parseJSON(event.data);

    if(data.type==2){
        $('#myModal').reveal(); 
   		setTimeout(function() { 
   		load($("#miao"))},1000);
    }
    

   
    
    
}
  

  
            
  
  
  });
  </script>
</html>
